#pragma once

#include <stddef.h>
#include "Singleton.h"
#include "ShmList.h"
#include "ShmBlock.h"

typedef CShmList<CShmBlock, CSpinLock> CShmLst;
typedef CShmLst::ListNode ShmNode;

class CShmMgr : public CSingleton<CShmMgr>
{
    friend class CSingleton;

public:
    ~CShmMgr();
    void operator delete(void *ptr);

private:
    CShmMgr();
    void *operator new(size_t sz);

public:
    void Destroy();

    ShmNode *CreateShmBlock(uint64_t nSize);
    void DestroyShmBlock(ShmNode *pNode);

private:
    CShmLst m_lstShm;
};
